package panda.query.scan;

import java.util.ArrayList;
import java.util.Map;

import panda.query.condition.ValueExpression;
import panda.query.struct.Attribute;
import panda.query.struct.Constant;
import panda.query.tree.QueryTreeNode;
import panda.transaction.Transaction;


public class ResultSetScanner implements Scanner {
	
	Scanner s;
	Transaction tx;
	Map<Attribute, ValueExpression> ve;
	
	public ResultSetScanner(Scanner s, Map<Attribute, ValueExpression> ve, Transaction tx) {
		this.s = s;
		this.tx = tx;
		this.ve = ve;
	}

	@Override
	public void close() {
		s.close();
	}

	@Override
	public Constant getValue(Attribute attr) {
		return ve.get(attr).evaluate(s, tx);
	}

	@Override
	public boolean hasAttribute(Attribute name) {
		return ve.containsKey(name);
	}

	@Override
	public void init() {
		s.init();
	}

	@Override
	public boolean next() {
		return s.next();
	}

}
